package cn.caijiapeng.spt.ctrl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jfinal.core.Controller;


public class DataCtrl extends Controller{
	public void table1(){
		Integer pageSize = getParaToInt("pageSize", 20);
		Integer pageNumber = getParaToInt("pageNumber", 1);
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("totalRow", 80);
		data.put("pageSize", pageSize);
		data.put("pageNumber", pageNumber);
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		for(int i = 0 ; i < pageSize ; i++) {
			Map<String, Object> m = new HashMap<String, Object>();
			m.put("id", i + 1);
			m.put("name", "孟子");
			m.put("nation", "华夏族（汉族）");
			m.put("outTime", "公元前-372年");
			m.put("motto", "猿强，则国强。国强，则猿更强！");
			list.add(m);
		}
		data.put("list", list);
		
		result.put("code", 0);
		result.put("message", "ok");
		result.put("data", data);
		renderJson(result);
	}
	
	public void edit(){
		Integer id = getParaToInt("id");
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> m = new HashMap<String, Object>();
		m.put("id", id);
		m.put("name", "孟子");
		m.put("nation", "华夏族（汉族）");
		m.put("outTime", "公元前-372年");
		m.put("motto", "猿强，则国强。国强，则猿更强！");
		result.put("code", 0);
		result.put("message", "ok");
		result.put("data", m);
		renderJson(result);
	}
	
	public void submit(){
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("code", 0);
		result.put("message", "操作成功");
		renderJson(result);
	}
}
